﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UIT.Controls.Containers;
using UIT.Controls.Template;
using System.Windows.Markup;
#if !SILVERLIGHT
using System.Xaml;
#endif
using System.Reflection;

namespace UIT.Controls.Template
{
    [ContentProperty("Template")]
    public class DataTemplate : ITemplate
    {

        #region ITemplate Members

        public IControl CreateInstance(object context)
        {
            DataTemplateInstance instance = new DataTemplateInstance(context,Template.CreateInstance());
            return instance;
        }

        #endregion

        #region ITemplate Members

#if !SILVERLIGHT
		[Ambient]
#endif
        public TemplateContent Template
        {
            get;
            set;
        }

        #endregion

        #region INotifyPropertyChanged Members

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
        }

        #endregion

        #region ITemplate Members


        public object Metadata
        {
            get;
            set;
        }

        #endregion

        public bool IsBoundTemplate { get; internal set; }
    }
}
